#include<iostream>

using namespace std;
typedef long long ll;
const int p=1e9+7;

ll qpow(ll a,ll b,ll c)
{
	ll ret=1;
	while(b)
	{
		if(b&1)
		{
			ret=ret*a%p;
		}

		b>>=1;
		a=a*a%p;
	}

	return ret;
}
int main()
{
	ll n;
	ll d=qpow(6,p-2,p);
	while(cin>>n)
	{
		ll a=n%p;
		ll b=(2*n+1)%p;
		ll c=(n+1)%p;

		cout<<(a*b)%p*c%p*d%p<<endl;
	}
}